package changceilingcolor003;

import java.io.File;
import java.util.ArrayList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

import toxi.geom.Vec3D;

public class Configuration {
	
	public Configuration(String sFileName)
	{
		try {

			DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
					.newInstance();
			DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
			Document doc = docBuilder.parse(new File(sFileName));

			// normalize text representation
			doc.getDocumentElement().normalize();

			String sWidth = ((Element) doc.getElementsByTagName("Width").item(0)).getTextContent();
			width = Integer.parseInt(sWidth);
			
			String sHeight = ((Element) doc.getElementsByTagName("Height").item(0)).getTextContent();
			height = Integer.parseInt(sHeight);
			
			String smaxZ = ((Element) doc.getElementsByTagName("maxZ").item(0)).getTextContent();
			maxZ = Integer.parseInt(smaxZ);
			 



		} catch (SAXParseException err) {
			System.out.println("** Parsing error" + ", line "
					+ err.getLineNumber() + ", uri " + err.getSystemId());
			System.out.println(" " + err.getMessage());

		} catch (SAXException e) {
			Exception x = e.getException();
			((x == null) ? e : x).printStackTrace();

		} catch (Throwable t) {
			t.printStackTrace();
		}
	}
	public int width= 0;
	public int height= 0;
	public int maxZ= 0;
}
